home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJLSR200.ZIP / src / libc / posix / sys / stat / mkdir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-29  |  926 b   |  45 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <libc/stubs.h>
  3. #include <errno.h>
  4. #include <sys/stat.h>
  5. #include <go32.h>
  6. #include <dpmi.h>
  7. #include <unistd.h>
  8. #include <libc/dosio.h>
  9.  
  10. int
  11. mkdir(const char *dirname, mode_t mode)
  12. {
  13.   __dpmi_regs r;
  14.  
  15.   _put_path(dirname);
  16.  
  17.   if(_USE_LFN)
  18.     r.x.ax = 0x7139;
  19.   else
  20.     r.h.ah = 0x39;
  21.   r.x.ds = __tb_segment;
  22.   r.x.dx = __tb_offset;
  23.   __dpmi_int(0x21, &r);
  24.  
  25.   if (r.x.flags & 1)
  26.   {
  27.     errno = __doserr_to_errno(r.x.ax);
  28.     if (errno == EACCES)
  29.     {
  30.       /* see if the directory existed, in which case
  31.      we should return EEXIST - DJ */
  32.       if (access(dirname, D_OK) == 0)
  33.     errno = EEXIST;
  34.     }
  35.     return -1;
  36.   }
  37.  
  38.   /* DOS ignores directory permissions, and mkdir is stub'd,
  39.      so rather than stub chmod also, just skip it.   DJ */
  40. /*  if (chmod(dirname, mode))
  41.     return -1; */
  42.   return 0;
  43. }
  44.  
  45.